# -*- coding:utf-8 -*-
# @Time:2023/7/14 22:26
# @Author: cevent
# @name=spider


import BiliUtil

if __name__ == '__main__':
    # 1.创建一个空的用户实例，空的用户实例不设置用户uid
    # biliUser = BiliUtil.User(uid='4093899')

    # 2.设定的cookie信息会影响到该实例及其包含的所有自动创建的对象
    # biliUser.set_cookie = 'SESSDATA=abcd68fd%2C1123761144%2C38d97xyz'

    # 多种方式设定用户uid
    # 方案一
    # ua = BiliUtil.User(uid='4093899')
    # 方案二
    # ua = BiliUtil.User()
    # ua.set_user(uid='4093899')
    # 方案三
    # ua = BiliUtil.User()
    # ua.set_by_url(url='https://space.bilibili.com/4093899')

    # 3.获取用户的基础信息
    # biliUser.get_user_info()

    # 4.仅获取视频列表而不下载视频，该操作将自动帮你完成用户信息的获取
    # biliUser.get_all_video_info()

    # 5.可以直接下载UP主的全部视频，该操作将自动帮你完成用户信息的获取与视频列表的获取。该操作支持设定路径、命名方式、视频时长，当设置了适合的cookie时，下载的画质将会自动提升。
    # biliUser.get_all_video_data(base_path='Download', name_path=True, max_length=None)

    # 下载高清视频
    cookie = input("buvid_fp=e769a2bd7d5c41c367964073084c4a23; buvid3=865ACEEC-5B51-02EA-846A-1F262267D79B29550infoc; b_nut=1651665368; buvid4=E65B0971-0D9D-23BF-22EB-9E0B657AF39E29550-022050419-CZkn1ddhkNBtFKRU2jVTAQ%3D%3D; rpdid=|(k|~lRRYJYu0J'uY~YR~RRYu; CURRENT_FNVAL=4048; _uuid=B4F510528-1ED2-AA5D-1038E-7E35B628E610212831infoc; b_lsid=167372E9_18954C7F438; PVID=1; csrf_state=3723743d7e5125994cf95048d98203cb; SESSDATA=2394d24d%2C1704900372%2C98f02%2A71lBNnAgj312I5BleDYYFH_8YD7h_w8fSXHr4hBswOPiYw10GUCnYE2JC8-3v6SWnRqztdNAAAMgA; bili_jct=40d7c7d68222102600f01e554113a531; DedeUserID=500040850; DedeUserID__ckMd5=dde2ec157de30c22; CURRENT_QUALITY=80; bp_video_offset_500040850=814517380642242600; sid=74v3k0b3")
    ua = BiliUtil.User(uid='500040850')
    ua.set_by_url('https://www.bilibili.com/video/BV1A5411G7UB/?spm_id_from=333.788.recommend_more_video.0&vd_source=92204d1d276f002ec40cc542532cb986')
    ua.set_cookie(cookie)
    ua.get_all_video_data(base_path='Download', name_path=True)
